package com.imooc.controller;

//import com.imooc.configuration.StudentConfiguration;
import com.imooc.pojo.MyConfig;
import com.imooc.pojo.Student;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
//import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class HelloWorldController {
//    @Autowired
//    private StudentConfiguration studentConfiguration;
//
//    @RequestMapping("/")
//    public String hello() {
//        return "Hello World!";
//    }
//
//    @RequestMapping("/student")
//    public String student() {
//        return studentConfiguration.getName() + "-" + studentConfiguration.getAge();
//    }

    @Autowired
    private Student stu;

    @GetMapping("getStu")
    public Object getStu() {
        return stu;
    }

    @Autowired
    private MyConfig myConfig;

    @GetMapping("getMyConfig")
    public Object getMyConfig() {
        return myConfig;
    }
    // 从application.yaml中获取配置属性
    @Value("${self.custom.config.sdkSecret}")
    private String sdkSecret;
    @Value("${self.custom.config.host}")
    private String host;
    @Value("${self.custom.config.port}")
    private String port;
    @Value("${app.name.xxx.yyy.zzz}")
    private String xyz;
    // 做输出
    @GetMapping("getYmlCustomConfig")
    public Object getYmlCustomConfig() {
        return sdkSecret + ";\t" + host + ":" + port + ";\t" + xyz;
    }
}
